package com.jonniespratley.generators.mysql.data
{
	import mx.utils.UIDUtil;
	[Bindable]
	public class Field extends Object
	{
		public var aField:String;
		public var aType:String;
		public var aNull:String;
		public var aKey:String;
		public var aDefault:String;
		public var aExtra:String;

		public var fieldUUID:String;

		public function  Field( obj:Object = null )
		{
			if ( obj != null )
			{
				this.aField = obj['Field'];
				this.aType = obj['Type'];
				this.aNull = obj['Null'];
				this.aKey = obj['Key'];
				this.aDefault = obj['Default'];
				this.aExtra = obj['Extra'];
			}
		}

		public function get label():String
		{
			return aField + ' ' + aType;
		}

		public function get column():String
		{
			return aField;
		}

		public function get type():String
		{
			return 'field';
		}

		public function get isRequired():Boolean
		{
			var required:Boolean;

			if ( aNull == 'NO' )
			{
				required = false;
			} else if ( aNull == 'YES' )
			{
				required = true;
			}

			return required;
		}

		public function get data():Object
		{
			return 'field';
		}

		public function createUUID():String
		{
			return UIDUtil.createUID();
		}
	}
}